const newsModal = require('../models/News');

module.exports = function ({ router, baseUrl, type, path, name}) {
    router.get(baseUrl + path, async (ctx, next) => {
        try {
            let reses = await Promise.all([
                newsModal.getList({ pageSize: 4, type}),
            ]);
            ctx.render('news/news.pug', { data: reses[0], name, href: path, baseUrl, ssr: true });
        } catch (err) {
            next(err);
        }
    });
}